﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Diagnostics;
using ImageCropper.Lib;

namespace ImageCropper
{
    public partial class CropRectangle : ResizableRectangle
    {
        public CropRectangle()
        {
            InitializeComponent();
        }

        protected override IEnumerable<ResizableRectangle> SnappableObjects
        {
            get { return this.Surface.Rectangles; }
        }
                
        private void UserControl_KeyDown(object sender, KeyEventArgs e)
        {
            _KeyDown(e, true, true);
        }

        private void UserControl_GotFocus(object sender, RoutedEventArgs e)
        {
            VisualStateManager.GoToState(this, "Focused", true);
        }
        private void UserControl_LostFocus(object sender, RoutedEventArgs e)
        {
            VisualStateManager.GoToState(this, "Unfocused", true);
        }        

        private void _center_MouseMove(object sender, MouseEventArgs e)
        {
            _Move(e);
        }        

        private void _northWestEdge_MouseMove(object sender, MouseEventArgs e)
        {
            _Resize(Direction.NorthWest, e);
        }
        private void _northEastEdge_MouseMove(object sender, MouseEventArgs e)
        {
            _Resize(Direction.NorthEast, e);
        }
        private void _northEdge_MouseMove(object sender, MouseEventArgs e)
        {
            _Resize(Direction.North, e);
        }
        private void _westEdge_MouseMove(object sender, MouseEventArgs e)
        {
            _Resize(Direction.West, e);
        }
        private void _eastEdge_MouseMove(object sender, MouseEventArgs e)
        {
            _Resize(Direction.East, e);
        }
        private void _southWestEdge_MouseMove(object sender, MouseEventArgs e)
        {
            _Resize(Direction.SouthWest, e);
        }
        private void _southEdge_MouseMove(object sender, MouseEventArgs e)
        {
            _Resize(Direction.South, e);
        }
        private void _southEastEdge_MouseMove(object sender, MouseEventArgs e)
        {
            _Resize(Direction.SouthEast, e);
        }              
    }    
}
